module lang.d.sts.expressions.dliteralexpression;

import lang.d.sts.declarations.ddeclaration;
import lang.d.sts.expressions.dexpression;
import lang.d.types.dtype;
import lang.d.visitors.dvisitor;

import std.variant;

// Parent?
class DLiteralExpression: DExpression {
    private Variant myValue;
    private TypeInfo myType;

    public this(TypeInfo type) {
        myType = type;
    }

    public bool isEqualType(TypeInfo type) {
        return (myType == type);
    }

    public void setValue(T)(T value) {
        if (typeid(T) != myType) {
            throw new Exception("Type error in literal expression");
        }
        myValue = value;
    }

    override public void accept(DVisitor visitor) {
        visitor.visitLiteralExpression(this);
    }
}
